<template>
    <div>
        <script id="editor" type="text/plain" />
    </div>
</template>
<script>
import '../../static/ueditor/ueditor.config.js';
import '../../static/ueditor/ueditor.all.js';
import '../../static/ueditor/lang/zh-cn/zh-cn.js';
import '../../static/ueditor/ueditor.parse.min.js';
export default {
    name: "UEditor",
    props: {
        initData: {
            type: String,
            default: ''
        },
        config: {
            type: Object,
            default: function() {
            	return {
            		enableAutoSave: false,
			        autoHeightEnabled: false,
			        initialFrameHeight: 350,
			        initialFrameWidth: '100%',
			        zIndex: 1200
            	}
            }
        }
    },
    data() {
        return {
            editor: null
        };
    },
    methods: {
    	init(content, type = 1) {
	      	this.editor = UE.getEditor('editor', this.config);
	      	this.editor.ready(() => {
	      		this.editor.setContent(content || '')
	      	})
	      	/*
            const _this = this;
            this.editor = window.UE.getEditor("editors", this.config); // 初始化UE
            if(type == 1){
                this.editor.addListener("ready", function() {
                    _this.editor.setContent(content);
                });
            } else {
                _this.editor.setContent(content);
            }*/
    	},
        getUEditor() {
            return this.editor;
        },
        getUEContent() {
            // 获取内容方法
            return this.editor.getContent();
        }
    },
    destroyed() {
        this.editor.destroy();
    },
};
</script>